<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

$api = app('Dingo\Api\Routing\Router');

$api->version(config('api.version'), [
    'namespace' => 'App\Http\Controllers\Api',
], function (\Dingo\Api\Routing\Router $api) {

    $api->group([
        'middleware' => ['getIp', 'language'],
        'limit' => env('API_LIMIT'),
        'expires' => env('API_EXPIRES'),
    ], function (\Dingo\Api\Routing\Router $api) {

        //忘记登录密码
        $api->put('forgot_password', 'AuthorizationController@forgetPassword');

        //忘记支付密码
        $api->put('forgot_pay_password', 'AuthorizationController@forgetPayPassword');

        //用户登录
        $api->post('login', 'AuthorizationController@login');

        //用户注册
        $api->post('register', 'AuthorizationController@store');

        //banner
        $api->get('banners', 'BannersController@index');

        //商家
        $api->get('shops', 'ShopsController@index');

        //商家详情
        $api->get('shops/{id}', 'ShopsController@show');

        //商品(套餐)列表
        $api->get('products', 'ProductsController@index');

        //商品(套餐)详情
        $api->get('products/{id}', 'ProductsController@show');

        //省接口
        $api->get('province', 'PublicController@ProvinceList');

        //市接口
        $api->get('city', 'PublicController@city');

        //区接口
        $api->get('district', 'PublicController@district');

        //上传图片
        $api->post('upload_image', 'UploadController@store');

        //上传视频
        $api->post('upload_video', 'UploadController@store');

        //发送邮件验证
        $api->post('verification_email', 'PublicController@sendVerificationEmail');

        //验证邮件验证码
        $api->post('check_verification_code', 'PublicController@checkVerificationCode');

        //设置手机设备信息
        $api->post('mobile_device', 'MobileDeviceController@updateOrCreate');

        //获取手机设备信息
        $api->get('mobile_device', 'MobileDeviceController@index');

        $api->post('test', 'TestController@index');

        //汇率列表
        $api->get('exchange_rates', 'ExchangeRateController@index');

        //支付方式
        $api->get('pay_methods', 'PayMethodController@index');

        // 需要 token 验证的接口
        $api->group(['middleware' => ['api.auth&refresh', 'login.auth']], function (\Dingo\Api\Routing\Router $api) {

            //修改登录密码
            $api->put('password', 'AuthorizationController@changePassword');

            //当前登录用户信息
            $api->get('me', 'AuthorizationController@me');

            //退出
            $api->get('logout', 'AuthorizationController@logout');

            //填写/修改基本资料
            $api->put('me', 'AuthorizationController@update');

            //修改支付密码
            $api->put('pay_password', 'AuthorizationController@changePayPassword');

            //发帖子
            $api->post('posts', 'PostsController@create');

            //获取钱包信息
            $api->get('wallet', 'WalletsController@index');

            //消息
            $api->get('messages', 'MessagesController@index');

            //消息数量
            $api->get('message_amount', 'MessagesController@amount');

            //收藏列表
            $api->get('collects/{type}', 'CollectsController@index');

            //添加收藏
            $api->post('collects', 'CollectsController@create');

            //订单列表
            $api->get('orders', 'OrdersController@index');

            //订单详情
            $api->get('orders/{id}', 'OrdersController@show');

            //点赞列表
            $api->get('likes/{type}', 'LikesController@index');

            //点赞
            $api->post('likes', 'LikesController@create');

            //资讯列表
            $api->get('news', 'NewsController@index');

            //资讯详情
            $api->get('news/{id}', 'NewsController@show');

            //友圈列表
            $api->get('posts', 'PostsController@index');

            //友圈详情
            $api->get('posts/{id}', 'PostsController@show');

            //评论详情
            $api->get('comments/{id}', 'CommentsController@show');

            //发表评论
            $api->post('comments', 'CommentsController@create');

            //商家路由组
            $api->group(['middleware' => 'seller.auth'], function (\Dingo\Api\Routing\Router $api) {

                //商家接单
                $api->put('receive_orders', 'OrdersController@receive');

                //商家完成订单
                $api->put('finish_orders', 'OrdersController@finish');

                //取消订单--商家
                $api->put('cancel_orders/seller', 'OrdersController@sellerCancel');

                //提现记录
                $api->get('log_balance', 'LogBalancController@index');

                //添加商品
                $api->post('products', 'ProductsController@create');

                //编辑商品
                $api->put('products', 'ProductsController@edit');

                //我的产品
                $api->get('my_products', 'ProductsController@myProducts');

                //上传商家距离
                $api->put('seller_distance', 'OrdersController@sellerDistance');

                //时间列表
                $api->get('schedules', 'SchedulesController@index');

                //添加时间
                $api->post('schedules', 'SchedulesController@create');

                //编辑时间
                $api->put('schedules', 'SchedulesController@edit');

                //删除时间
                $api->delete('schedules', 'SchedulesController@destroy');

                //申请提现
                $api->post('withdraw', 'PaymentController@createWithdraw');

                //提现列表
                $api->get('withdraw', 'PaymentController@withdrawList');

                //美拍
                $api->get('pictures', 'PictureController@index');

                //提交美拍
                $api->post('pictures', 'PictureController@create');

                //删除美拍
                $api->delete('pictures/{id}', 'PictureController@delete');
            });

            //客户路由组
            $api->group(['middleware' => 'customer.auth'], function (\Dingo\Api\Routing\Router $api) {

                //提交订单
                $api->post('orders', 'OrdersController@create');

                //支付订单
                $api->put('pay_orders', 'OrdersController@pay');

                //用户确认签到
                $api->put('signed_orders', 'OrdersController@signed');

                //用户确认服务开始
                $api->put('confirm_orders', 'OrdersController@confirm');

                //取消订单--用户
                $api->put('cancel_orders/user', 'OrdersController@userCancel');

                //验证退款码
                $api->put('verify_orders', 'OrdersController@refundVerify');

                //上传用户距离
                $api->put('user_distance', 'OrdersController@userDistance');

                //提交申诉
                $api->post('work_orders', 'HelpOrdersController@create');

                //充值
                $api->post('top_up', 'PaymentController@createTopUp');

                //充值列表
                $api->get('top_up', 'PaymentController@topUpList');
            });

            //聊天--登录
            $api->post('chat_login', 'ChatController@login');

            //聊天--退出
            $api->post('chat_logout', 'ChatController@logout');

            //聊天--发消息
            $api->post('chat_send', 'ChatController@sendMsg');
        });
    });

});



